// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2013 Huawei Ltd.
 * Author: Jiang Liu <liuj97@gmail.com>
 *
 * Copyright (C) 2014-2016 Zi Shen Lim <zlim.lnx@gmail.com>
 */
#include <linux/bitops.h>
#include <linux/bug.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/smp.h>
#include <linux/spinlock.h>
#include <linux/stop_machine.h>
#include <linux/types.h>
#include <linux/uaccess.h>
#include <linux/set_memory.h>

#include <asm/cacheflush.h>
#include <asm/debug-monitors.h>
#include <asm/fixmap.h>
#include <asm/insn.h>
#include <asm/sections.h>

void *liblinux_patch_map(void *addr, int fixmap)
{
	unsigned long addr_align = (uintptr_t)addr;

	addr_align = ALIGN_DOWN(addr_align, PAGE_SIZE);

	set_memory_rw(addr_align, 1);
	return addr;
}

void liblinux_patch_unmap(void *addr)
{
	unsigned long addr_align = (uintptr_t)addr;

	addr_align = ALIGN_DOWN(addr_align, PAGE_SIZE);
	set_memory_x(addr_align, 1);
}
